package com.zsc.spring.study.applicationEvent;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 需要获取到applicationEventPublisher进行事件发布
 */
@Component
public class EmailService implements ApplicationEventPublisherAware {

    private List<String> blackList;

    ApplicationEventPublisher applicationEventPublisher;

    public void setBlackList(List<String> blackList){
        this.blackList = blackList;
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher = applicationEventPublisher;
    }

    public void sendEmail(String address,String content){
        System.out.println("�����¼�");
        applicationEventPublisher.publishEvent(new MyApplicationEvent(this,address,content));
        return;
    }

}
